#ifndef PLAYER_H_
#define PLAYER_H_

#include "Object.h"
#include "Units/Unit.h"
#include "Faction.h"

#include <boost/shared_ptr.hpp>
#include <set>

namespace OOInterface {



typedef std::set< ConstUnitPtr > ConstUnitSet;

class Player: public Object
{
public:
	Player( int id );
	virtual ~Player();

	void changeTeam( ConstTeamPtr team );
	ConstTeamPtr getTeam() const;
	bool isAllyOf( ConstPlayerPtr p ) const;
	bool isEnemyOf( ConstPlayerPtr p ) const;

	ConstUnitSet getUnits() const;
	void addUnit( ConstUnitPtr unit );
	void removeUnit( ConstUnitPtr unit );


	/**
	 * getResourceAmount( ... ):
	 * Gets the total amount of the specified resource that the Player has
	 * currently stored. This will only return a meaningful value if the
	 * person querying is priveleged to such information (e.g. The AI should only
	 * ask its' own Player representation for Resource information)
	 *
	 * @return The amount of the resource that the Player has stored.
	 */
	float getResourceAmount( const Resource& r ) const;
	void setResourceAmount( const Resource& r , float amt );

	float getResourceStorage( const Resource& r ) const;
	void setResourceStorage( const Resource& r, float storage );

	float getResourceUsage( const Resource& r ) const;
	void setResourceUsage( const Resource& r, float usage );

	float getResourceIncome( const Resource& r ) const;
	void setResourceIncome( const Resource& r, float income );

	const Faction& getFaction() const { return _faction; }
	void setFaction( const Faction& f ) { _faction = f; }

	int getID() const { return _id; }

	virtual std::string toString() const;

private:
	int _id;
	Faction _faction;

	ConstTeamPtr _team;
	ConstUnitSet _units;

	typedef std::map< const Resource, float> ResourceMap;
	ResourceMap _resources;
	ResourceMap _resourceStorage;
	ResourceMap _resourceIncome;
	ResourceMap _resourceUsage;
};

}

#endif /*PLAYER_H_*/
